<%@page language="java" pageEncoding="UTF-8"
	contentType="text/html;charset=utf-8"%>
<%@include file="/includes/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>

<script type="text/javascript">
    <!-- 
    $(document).ready(function() {
    	$("#doSaveBtn").click(function() {
    		var editUserName = $('#createUserName').val();//姓名
    		var editUserPhoneNo = $('#editUserPhoneNo').val();//電話
    		var editUserEmail = $('#editUserEmail').val();//E-MAIL
    		var editCertificateKey = $("#editCertificateKey").val();//憑證序號 	
    		var editUserNote = $('#editUserNote').val();//備註
    		var value2 = editUserName.replace(/^\s+|\s+$/g,'');
    		var value3 = editUserPhoneNo.replace(/^\s+|\s+$/g,'');
    		var value4 = editUserEmail.replace(/^\s+|\s+$/g,'');
    		var value5 = editCertificateKey.replace(/^\s+|\s+$/g,'');
    		var value6 = editUserNote.replace(/^\s+|\s+$/g,'');
    		var emailRegExp = /[a-zA-Z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?/;
			var editUserPhoneNoRegExp = /^0[0-9]{1,3}\-\d{5,8}$/;
    		var errorMessage = '';
    		if (value2.length <= 0){
    			if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    errorMessage = errorMessage + '姓名不可空白!!';
    		} else {
    			var count = editUserName.length;
				 var strLength = 0;					 
				 for(var i = 0; i < count; i++){
					  if(editUserName.charCodeAt(i) < 0 || editUserName.charCodeAt(i) > 255){
					   	strLength += 3;//漢字編碼在0-255之外，oracle數據庫是UTF-8編碼，一個漢字，對應數據庫varchar2的3個byte。
					  }else{
					  	 strLength += 1;
					  }
				 }
				 if(strLength > 50){
				 	 if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    	 errorMessage = errorMessage + '姓名不可超過50碼!!';
				 }
    		}
    		if(value3.length > 0){
   				if(!editUserPhoneNoRegExp.test(value3)){
    				if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    	 errorMessage = errorMessage + '[電話號碼]格式錯誤,格式為0x-xxxxxxxx!!';
    			}
    		}
    		if (value4.length <= 0){
    			if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    errorMessage = errorMessage + 'E-MAIL不可空白!!';
    		} else {
    			if(!emailRegExp.test(editUserEmail)){
    				if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    errorMessage = errorMessage + '[E-MAIL]格式錯誤!!';
    			}else{
    				var count = editUserEmail.length;
					 var strLength = 0;					 
					 for(var i = 0; i < count; i++){
						  if(editUserEmail.charCodeAt(i) < 0 || editUserEmail.charCodeAt(i) > 255){
						   	strLength += 3;//漢字編碼在0-255之外，oracle數據庫是UTF-8編碼，一個漢字，對應數據庫varchar2的3個byte。
						  }else{
						  	 strLength += 1;
						  }
					 }
					 if(strLength > 100){
					 	 if (errorMessage != '') errorMessage = errorMessage + '<br>';
	    		    	 errorMessage = errorMessage + 'E-MAIL不可超過100碼!!';
					 }
    			}
    			
    		}
    		if (value5.length > 0)
   		 {  			
   				var count = editCertificateKey.length;
				 var strLength = 0;					 
				 for(var i = 0; i < count; i++){
					  if(editCertificateKey.charCodeAt(i) < 0 || editCertificateKey.charCodeAt(i) > 255){
					   	strLength += 3;//漢字編碼在0-255之外，oracle數據庫是UTF-8編碼，一個漢字，對應數據庫varchar2的3個byte。
					  }else{
					  	 strLength += 1;
					  }
				 }
				 if(strLength > 30){
				 	 if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    	 errorMessage = errorMessage + '憑證序號不可超過30碼!!';
				 }
    		}
    		if (value6.length > 0)
    		{
    			 var count = editUserNote.length;
				 var strLength = 0;					 
				 for(var i = 0; i < count; i++){
					  if(editUserNote.charCodeAt(i) < 0 || editUserNote.charCodeAt(i) > 255){
					   	strLength += 3;//漢字編碼在0-255之外，oracle數據庫是UTF-8編碼，一個漢字，對應數據庫varchar2的3個byte。
					  }else{
					  	 strLength += 1;
					  }
				 }
				 if(strLength > 100){
				 	 if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    	 errorMessage = errorMessage + '備註不可超過100碼!!';
				 } 			
    		}
            if (errorMessage != '')
            {	
            	showErrorMessageDialog(errorMessage);
            	return false;
            }
           	return true;
		});
		
		/* 用戶群組（GROUP）下拉選單的值改變事件 */
		$('#qrySelectGroup').change(function() {
            $('#qrySelectGroupBtn').click();
		});
		
		//全選 
      $('#checkboxAll').click(function() 
        {
         var chk = $('#checkboxAll').attr('checked');   			
         $('#queryUserForm input:checkbox').each(function(){  
         
         if("checked"==chk){ 
    		 $(this).attr('checked', chk);
    		}  				
    	else{
			 $(this).removeAttr('checked');
    		}
           });
        });
         
		//取消
		$("#doCancelBtn").click(function() {
			$("#hidden\\.doCancelBtn").trigger('click');
		});
		
		
		<c:if test="${not empty actionBean.message}">
   			showMessageDialog('<c:out value="${actionBean.message }" escapeXml="false"/>');
		</c:if>	
    });
    
    //-->
    </script>
</head>
<body>
<div id="smallQueryForm"></div>
<stripes:form id="queryUserForm"
	beanclass="com.feib.stms.action.Stms9006ActionBean" method="post">
	<div id="queryForm">
	<table>
		<tr>
			<td colspan="5" class="queryHeader">使用者修改</td>
		</tr>
		<tr>
			<th>使用者ID<span id="mustKeyInStar">**</span></th>
			<td><stripes:text id="editUserId" name="editUser.userId"
				size="15" maxlength="12" disabled="true" />
				<br>
				<c:out value="${actionBean.showEditUser.userId }" />
			</td>
			<th>姓名<span id="mustKeyInStar">**</span></th>
			<td colspan="2"><stripes:text id="createUserName"
				name="editUser.userName" size="25" maxlength="30" />
				<br>
				<c:out value="${actionBean.showEditUser.userName }" />
			</td>
		</tr>
		<tr>
			<th>電話</th>
			<td><stripes:text id="editUserPhoneNo"
				name="editUser.userPhoneNo" size="15" maxlength="12" /><c:out
				value="${actionBean.showEditUser.userPhoneNo }" /></td>
			<th>E-MAIL<span id="mustKeyInStar">**</span></th>
			<td colspan="2"><stripes:text id="editUserEmail"
				name="editUser.userEmail" size="30" maxlength="40" />
				<br>
				<c:out value="${actionBean.showEditUser.userEmail }" />
			</td>
		</tr>
		<tr>
			<th>啟用</th>
			<td><stripes:select id="editEnabled" name="editUser.enabled">
				<stripes:option value="true" label="是" />
				<stripes:option value="false" label="否" />
			</stripes:select><c:if
				test="${!empty actionBean.showEditUser && actionBean.showEditUser.enabled eq true }">
				<c:out value="是" />
			</c:if><c:if
				test="${!empty actionBean.showEditUser && actionBean.showEditUser.enabled eq false}">
				<c:out value="否" />
			</c:if></td>
			<th>鎖定</th>
			<td colspan="2"><stripes:select id="editLocked"
				name="editUser.locked">
				<stripes:option value="true" label="是" />
				<stripes:option value="false" label="否" />
			</stripes:select> <c:if
				test="${!empty actionBean.showEditUser  && actionBean.showEditUser.locked eq true}">
				<c:out value="是" />
			</c:if><c:if
				test="${!empty actionBean.showEditUser  && actionBean.showEditUser.locked eq false}">
				<c:out value="否" />
			</c:if></td>
		</tr>
		<tr>
			<th>憑證序號</th>
			<td><stripes:text id="editCertificateKey"
				name="editUser.certificateKey" size="30" maxlength="30" />
				<br>
				<c:out value="${actionBean.showEditUser.certificateKey }" />
			</td>
			<th>備註</th>
			<td colspan="2"><stripes:text id="editUserNote"
				name="editUser.userNote" size="30" maxlength="100" />
				<br>
				<c:out value="${actionBean.showEditUser.userNote }" />
			</td>
		</tr>
		<c:if test="${!actionBean.isBankGroupUser}">
			<tr>
				<th>可處理資料</th>
				<td colspan="4"><c:if
					test="${!empty actionBean.dealSecuritiesNos }">
					<input type="checkbox" name="checkboxAll" id="checkboxAll"
						value="全選" />全選&nbsp;
						<c:forEach items="${actionBean.dealSecuritiesNos}"
						var="dealSecuritiesNosObj" varStatus="rowstat">
						<input name="qryDealSecuritiesNos[${rowstat.index}]"
							type="checkbox" id="qryDealSecuritiesNos[${rowstat.index}]"
							<c:if test="${dealSecuritiesNosObj.checked }">checked="checked"</c:if>
							value="<c:out value='${dealSecuritiesNosObj.value}'/>" />
						<c:out value="${dealSecuritiesNosObj.label}" />&nbsp;	
						</c:forEach>
				</c:if> <br> <c:forEach
					items="${actionBean.showDealSecuritiesNos}"
					var="showDealSecuritiesNo" varStatus="rowstat">
					<c:out value="${showDealSecuritiesNo.label }" /> &nbsp;
							</c:forEach></td>
			</tr>
			<tr>
				<th>所屬分公司</th>
				<td colspan="4"><stripes:select id="editSecurities_Pk"
					name="editUser.securities.securitiesPk">
					<c:forEach items="${actionBean.securitiesOptionList }" var="viewObj"
						varStatus="rowstat">
						<stripes:option value="${viewObj.securitiesPk }"
							label="${viewObj.securitiesName }" />
					</c:forEach>
				</stripes:select> <c:out
					value="${actionBean.showEditUser.securities.securitiesName }" />&nbsp;
				</td>
			</tr>
		</c:if>
		<tr>
			<th>登入狀態</th>
			<td><c:if
				test="${!empty actionBean.editUser.userLoginControl && actionBean.editUser.userLoginControl.actived }">
				<c:out value="登入" />
			</c:if> <c:if test="${!actionBean.editUser.userLoginControl.actived }">
				<c:out value="離線" />
			</c:if></td>

			<th>上次登入時間</th>
			<td colspan="2"><fmt:formatDate
				value="${actionBean.editUser.lastLoginDate}"
				pattern="yyyy/MM/dd HH:mm:ss" /></td>
		</tr>
		<tr>
			<th>密碼有效時間</th>
			<td colspan="4"><fmt:formatDate
				value="${actionBean.editUser.pwdExpiredDate}"
				pattern="yyyy/MM/dd HH:mm:ss" /></td>
		</tr>
		<tr>
			<td colspan="5" class="queryFunction"><stripes:hidden
				name="editUser.userPk" /> <stripes:hidden name="editUser.userId" />
			<stripes:hidden name="operation" /> <stripes:hidden
				name="confirmIfTemp" /> <stripes:hidden
				name="editUser.group.groupPk" /> <stripes:submit id="doSaveBtn"
				name="doSave" value="確認" class="formBtn" /> <stripes:submit
				id="doCancelBtn" name="doCancel" value="取消" class="formBtn" /></td>
		</tr>
	</table>
	</div>
	<!-- 查詢條件 -->
	<stripes:hidden id="hidden.qryGroupNoForm" name="qryGroupNoForm" />
	<stripes:hidden id="hidden.qryGroupNameForm" name="qryGroupNameForm" />
	<!-- 分頁信息 -->
	<stripes:hidden id="hidden.queryResult.pageNumber"
		name="queryResult.pageNumber" />
	<stripes:hidden id="hidden.queryResult.sortCriterion"
		name="queryResult.sortCriterion" />
	<stripes:hidden id="hidden.queryResult.sortDirection"
		name="queryResult.sortDirection" />
</stripes:form>

<!-- 取消使用 -->
<div style="display: none;"><stripes:form
	id="hidden.queryUserForm"
	beanclass="com.feib.stms.action.Stms9006ActionBean" method="post"
	onsubmit="javascript: waitingDialog({});">
	<!-- 查詢條件 -->
	<stripes:hidden id="hidden.qryUserIdForm" name="qryUserIdForm" />
	<stripes:hidden id="hidden.qryUserNameForm" name="qryUserNameForm" />
	<!-- 分頁信息 -->
	<stripes:hidden id="hidden.queryResult.pageNumber"
		name="queryResult.pageNumber" />
	<stripes:hidden id="hidden.queryResult.sortCriterion"
		name="queryResult.sortCriterion" />
	<stripes:hidden id="hidden.queryResult.sortDirection"
		name="queryResult.sortDirection" />
	<stripes:submit id="hidden.doCancelBtn" name="doCancel" value="取消"
		class="formBtn" />
</stripes:form></div>
</body>
</html>
